import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue'),
    meta: { title: '登录' }
  },
  {
    path: '/',
    component: () => import('@/layout/index.vue'),
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: '首页', permission: 'dashboard' }
      },
      {
        path: 'profile',
        name: 'Profile',
        component: () => import('@/views/profile/index.vue'),
        meta: { title: '个人中心', permission: 'profile' },
        redirect: '/profile/info',
        children: [
          {
            path: 'info',
            name: 'ProfileInfo',
            component: () => import('@/views/profile/info.vue'),
            meta: { title: '个人信息', permission: 'profile:info' }
          },
          {
            path: 'password',
            name: 'ProfilePassword',
            component: () => import('@/views/profile/password.vue'),
            meta: { title: '修改密码', permission: 'profile:password' }
          }
        ]
      },
      {
        path: 'notification',
        name: 'Notification',
        component: () => import('@/views/notification/index.vue'),
        meta: { title: '通知管理', permission: 'notification' },
        redirect: '/notification/list',
        children: [
          {
            path: 'list',
            name: 'NotificationList',
            component: () => import('@/views/notification/list.vue'),
            meta: { title: '通知列表', permission: 'notification:list' }
          },
          {
            path: 'publish',
            name: 'NotificationPublish',
            component: () => import('@/views/notification/publish.vue'),
            meta: { title: '发布通知', permission: 'notification:publish' }
          }
        ]
      },
      {
        path: 'course',
        name: 'Course',
        component: () => import('@/views/course/index.vue'),
        meta: { title: '课程管理', permission: 'course' },
        redirect: '/course/list',
        children: [
          {
            path: 'list',
            name: 'CourseList',
            component: () => import('@/views/course/list.vue'),
            meta: { title: '课程列表', permission: 'course:list' }
          },
          {
            path: 'manage',
            name: 'CourseManage',
            component: () => import('@/views/course/manage.vue'),
            meta: { title: '课程管理', permission: 'course:manage' }
          }
        ]
      },
      {
        path: 'selection',
        name: 'Selection',
        component: () => import('@/views/selection/index.vue'),
        meta: { title: '选课管理', permission: 'selection' },
        redirect: '/selection/available',
        children: [
          {
            path: 'available',
            name: 'SelectionAvailable',
            component: () => import('@/views/selection/available.vue'),
            meta: { title: '可选课程', permission: 'selection:available' }
          },
          {
            path: 'selected',
            name: 'SelectionSelected',
            component: () => import('@/views/selection/selected.vue'),
            meta: { title: '已选课程', permission: 'selection:selected' }
          },
          {
            path: 'approval',
            name: 'SelectionApproval',
            component: () => import('@/views/selection/approval.vue'),
            meta: { title: '选课审批', permission: 'selection:approval' }
          }
        ]
      },
      {
        path: 'score',
        name: 'Score',
        component: () => import('@/views/score/index.vue'),
        meta: { title: '成绩管理', permission: 'score' },
        redirect: '/score/query',
        children: [
          {
            path: 'query',
            name: 'ScoreQuery',
            component: () => import('@/views/score/query.vue'),
            meta: { title: '成绩查询', permission: 'score:query' }
          },
          {
            path: 'input',
            name: 'ScoreInput',
            component: () => import('@/views/score/input.vue'),
            meta: { title: '成绩录入', permission: 'score:input' }
          },
          {
            path: 'analysis',
            name: 'ScoreAnalysis',
            component: () => import('@/views/score/analysis.vue'),
            meta: { title: '成绩分析', permission: 'score:analysis' }
          }
        ]
      },
      {
        path: 'system',
        name: 'System',
        component: () => import('@/views/system/index.vue'),
        meta: { title: '系统管理', permission: 'system' },
        redirect: '/system/users',
        children: [
          {
            path: 'users',
            name: 'SystemUser',
            component: () => import('@/views/system/users/index.vue'),
            meta: { title: '用户管理', permission: 'system:user' }
          },
          {
            path: 'roles',
            name: 'SystemRole',
            component: () => import('@/views/system/roles/index.vue'),
            meta: { title: '角色管理', permission: 'system:role' }
          },
          {
            path: 'menus',
            name: 'SystemMenu',
            component: () => import('@/views/system/menus/index.vue'),
            meta: { title: '菜单管理', permission: 'system:menu' }
          }
        ]
      }
    ]
  },
  {
    path: '/403',
    name: '403',
    component: () => import('@/views/error/403.vue'),
    meta: { title: '403' }
  },
  {
    path: '/:pathMatch(.*)*',
    name: '404',
    component: () => import('@/views/error/404.vue'),
    meta: { title: '404' }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router 